// 三星 https://iai.sh.cn/problem/426
#include <bits/stdc++.h>
using namespace std;
int x[100002];
int s[100002];
int main() {
  int k;
  cin >> k;
  int t = 0;
  for (int i = 1; i <= k; i++) {
    cin >> x[i];
    t = t ^ x[i];
  }
  x[k + 1] = t;
  int m = k + 1; // 循环节的长度
  s[0] = 0;
  for (int i = 1; i <= m; i++) {
    s[i] = s[i - 1] ^ x[i]; // 递推求出 “类似前缀和”——前i项目的异或值
  }

  int q;
  cin >> q;
  for (int i = 1; i <= q; i++) {
    int L, R;
    cin >> L >> R;
    R = R % m;
    if (R == 0)
      R += m;
    L = L % m;
    if (L == 0)
      L += m;
    int ans = s[R] ^ s[L - 1];
    cout << ans << endl;
  }

  return 0;
}